/**
 * @projectName leetode
 * @package cn.leetcode
 * @className cn.leetcode.t530
 * @copyright Copyright 2020 Thunisoft, Inc All rights reserved.
 */
package cn.leetcode;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

/**
 * t530
 * @description
 * @author fei
 * @date 2025/9/12 11:30
 * @version 1.0
 */
public class t530 {
    TreeNode pre;
    private int ans = Integer.MAX_VALUE;
    public int getMinimumDifference(TreeNode root) {
        if (root == null){
            return 0;
        }
        dfs(root);
        return ans;
    }
    public void dfs(TreeNode root){
        if (root == null){
            return;
        }
        dfs(root.left);
        if (pre != null){
            ans = Math.min(ans, root.val - pre.val);
        }
        pre = root;
        dfs(root.right);
    }
}
